let app = getApp()
let request = require('../../utils/request')

Page({

  /**
   * 页面的初始数据
   */
  data: {
    barHeight: wx.getMenuButtonBoundingClientRect().bottom,
    pageNum: 1,
    pageSize: 20,
    pageFlag: false,
    subscribeList: [],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
   
    this.getSubscribeList()
  },
  onReady: function () {

  },
  
  /**
   * 获取预约列表
   */
  getSubscribeList(next) {
    let that = this
    let parmas = {
      pageNum: this.data.pageNum,
      pageSize: this.data.pageSize,
      status: 2,
      parkId: wx.getStorageSync('parkInfo').parkId
    }
    request.http('/shop/shop-info/get-by-manage-id', 'GET', {manageId:'1463074615969275905'})
      .then(res => {
        let data = res.data
        let subscribeList = that.data.subscribeList
        let pageFlag = that.data.pageFlag;
        if (data.code == 200) {
          if (next) {
            if (data.data.length > 0) {
              subscribeList = subscribeList.concat(data.data)
              pageFlag = false
            } else {
              pageFlag = true
            }
          } else {
            subscribeList = data.data
          }
          this.setData({
            subscribeList,
            pageFlag
          })
          console.log(this.data.subscribeList)
        }
      }).catch(err => {
      
      })
  },
  /**
   * 触底加载
   */
  scrollTolower() {
    if (this.data.pageFlag) {
      return
    }
    this.setData({
      pageFlag: true,
      pageNum: this.data.pageNum + 1
    })
    this.getSubscribeList(true)
  },
  /**
   * 返回
   */
  back(){
    wx.navigateBack({ delta: 1 })
  }
})